package com.cmty256.cmuser.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cmty256.cmuser.service.UserService;
import com.cmty256.common.model.entity.UserDO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author chenmeng
 */
@RestController
@RequestMapping("/test")
public class CmTestController {

    @Resource
    private UserService userService;

    @GetMapping("/page")
    public Page<UserDO> testPage() {
        long begin = System.currentTimeMillis();
        Page<UserDO> objectPage = new Page<>(2, 2);
        Page<UserDO> page = userService.page(objectPage, Wrappers.<UserDO>lambdaQuery()
                .select(UserDO::getId, UserDO::getUserAccount));
        System.out.println("耗时：" + (System.currentTimeMillis() - begin));
        System.out.println(page.getCurrent());

        return page;
    }
}
